# L = ['Michael', 'Sarah', 'Tracy', 'Bob', 'Jack']
# s=L[0:3]
# print(s)


# def trim(s):
#     while s[:1] == ' ':
#         s = s[1:]
#     while s[-1:] == ' ':
#         s = s[:-1]
#     return s

# # 测试:
# if trim('hello  ') != 'hello':
#     print('测试失败!')
# elif trim('  hello') != 'hello':
#     print('测试失败!')
# elif trim('  hello  ') != 'hello':
#     print('测试失败!')
# elif trim('  hello  world  ') != 'hello  world':
#     print('测试失败!')
# elif trim('') != '':
#     print('测试失败!')
# elif trim('    ') != '':
#     print('测试失败!')
# else:
#     print('测试成功!')

# str='     hello         '
# trim(str)

L=[0,1,2,3,4,5,6,7]
print(L[-1]) # 最后一个元素内容 7
print(L[:-1]) # 从头到最后一个之前 [0, 1, 2, 3, 4, 5, 6]
print(L[-1:]) # 最后一个 [7]